using UnityEngine;

public class ShowRankUI : MonoBehaviour
{
	public UIEventListener closebtn;

	public UISprite rankflag;

	//public Animation scaleanima;
	public Animator animator;

	private GameObject objui;

	private bool isshow;

	private void Start()
	{
		closebtn.onClick = OnClickcloseBtn;
	}

	public void enable()
	{
		if (objui == null)
		{
			objui = base.gameObject;
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: true);
		isshow = true;
		/* scaleanima["PopWinAnimation"].time = 0f;
		scaleanima["PopWinAnimation"].speed = 1f;
		scaleanima.Play(); */
		animator.SetTrigger("popWin1");
		expshow();
	}

	public void expshow()
	{
		expdata exp = GamePlayerprefs.instance.GetExp(-1);
		if (exp.level >= 19)
		{
			rankflag.spriteName = "19." + GamePlayerprefs.instance.ranknameImage[exp.level - 1];
			rankflag.SetDimensions(78, 67);
			rankflag.transform.localPosition = new Vector3(-2f, -20f, 0f);
			return;
		}
		rankflag.spriteName = string.Empty + exp.level + "." + GamePlayerprefs.instance.ranknameImage[exp.level - 1];
		if (exp.level >= 15)
		{
			rankflag.SetDimensions(78, 67);
			rankflag.transform.localPosition = new Vector3(-2f, -20f, 0f);
		}
		else if (exp.level <= 14)
		{
			rankflag.SetDimensions(64, 70);
			rankflag.transform.localPosition = new Vector3(0f, -20f, 0f);
		}
	}

	public void OnClickcloseBtn(GameObject btn)
	{
		if (isshow)
		{
			isshow = false;
			/* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
			animator.SetTrigger("popWin2");
			Invoke("disable", animator.runtimeAnimatorController.animationClips[0].length);
		}
	}

	public void disable()
	{
		gamebackctl.instance.BackGameUIstate();
		UnityVersionUtil.SetActiveRecursive(objui, state: false);
	}
}
